import Utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * 关于Utils中的JDBCUtils的使用
 * 注意：该项目不能够重复运行需要改变插入数据
 * @author Mc.Chai
 * @program: JavaWeb
 * @create 2021-12-16-19:59 19:59
 */
public class UtilsDemo {
    public static void main(String[] args) {
        Connection connection=null;
        PreparedStatement preparedStatement=null;
        try {
            connection = JDBCUtils.getConnection();
            String sql="insert into user values (3,?,?)";
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,"王五");
            preparedStatement.setDouble(2,4000);
            preparedStatement.executeUpdate();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtils.close(preparedStatement,connection);
        }
    }
}
